package net.huashitong.synthetical.student.web;

import com.sirdc.modules.core.web.JsonBaseController;
import com.sirdc.modules.core.web.model.JqGrid;
import com.sirdc.modules.core.web.model.Message;
import net.huashitong.synthetical.newSupervision.entity.TaskNew;
import net.huashitong.synthetical.student.entity.DemoStudent;
import net.huashitong.synthetical.student.filter.DemoStudentFilter;
import net.huashitong.synthetical.student.service.DemoStudentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName DemoStudentController
 * @Description TODO
 * @Author LK
 * @Date 2019/6/4 15:48
 * @Version V1.0
 **/
@Controller
@RequestMapping(value = "/test")
public class DemoTaskController extends JsonBaseController {

    @Autowired
    private DemoStudentService demoStudentService;

    @Override
    protected String getView(String view) {
        return "/modules/student/" + view;
    }

    @RequestMapping(method = RequestMethod.GET)
    public String initPage(Model model) {
        return getView("task-query");
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST)
    public JqGrid query(DemoStudentFilter filter) {
        List<DemoStudent> demoStudents = demoStudentService.query(filter);
        return coverJqGrid(filter, demoStudents);
    }

    @RequestMapping("/filter")
    public String filter(DemoStudentFilter demoStudentFilter, Model model) {
        return getView("filter");
    }

    //------------------------上面不用管-----------------------------------

    /**
     *返回新增页面
     *
     * @param model
     * @return url
     */
    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public String showAddView(TaskNew taskNew, Model model) {
        return getView("task-form");
    }


}
